package com.example.multitenancy01.util;


import com.example.multitenancy01.config.MyContext;
import com.example.multitenancy01.entity.User;
import lombok.extern.slf4j.Slf4j;

/**
 *  工具类
 */
@Slf4j
public class JudgeUtil {

    /**
     *   TenantId 判断是否相等
     * @return
     */
    public boolean judgeTenantId(User user){
        boolean  flag = false;
        MyContext apiContext = (MyContext) SpringUtil.getBean("myContext");
        Long currentTenantId = apiContext.getCurrentTenantId();
        Long tenantId = user.getTenantId();
        if(currentTenantId.equals(tenantId)){
            flag = true;
            log.info("多租户Id 一致");
        }else{
            log.info("多租户Id 不一致");
        }
        return flag;
    }

}
